using System;
using System.Collections.Generic;
using System.Text;
using ENTITIES;
using DAL;
using Utility;

namespace BUS
{
  public  class DiemDenBUS
    {
        public static void Insert(TBDiemDen dd)
        {
            DiemDenDAL ddDAL = new DiemDenDAL();
            ddDAL.Insert(dd);
        }
        public static void Update(TBDiemDen dd)
        {
            DiemDenDAL ddDAL = new DiemDenDAL();
            ddDAL.Update(dd);
        }
        public static void Delete(int iD)
        {
            DiemDenDAL ddDAL = new DiemDenDAL();
            ddDAL.Delete(iD);
        }
        public static tbDiemDenCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DiemDenDAL ddDAL = new DiemDenDAL();
            return ddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDiemDenCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiemDenDAL ddDAL = new DiemDenDAL();
            return ddDAL.Get(cri.Criter, 0, 0, tbDiemDenColumns.MaDiemDen.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static TBDiemDen GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDiemDenColumns.MaDiemDen.ToString(), Condition.EQUAL, iD);
            DiemDenDAL ddDAL = new DiemDenDAL();
            tbDiemDenCollection diemdencollection = ddDAL.Get(cri.Criter,
                  0, 0, tbDiemDenColumns.MaDiemDen.ToString(), OrderDirection.ASC.ToString(), out total);
            if (diemdencollection.Count > 0)
                return diemdencollection[0];
            return null;
        }
        public static tbDiemDenCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiemDenDAL ddDAL = new DiemDenDAL();
            return ddDAL.Get(cri.Criter, 1, number,
             tbDiemDenColumns.MaDiemDen.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDiemDenCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiemDenDAL ddDAL = new DiemDenDAL();
            return ddDAL.Get(cri.Criter, 1, number,
               tbDiemDenColumns.MaDiemDen.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
}
